package com.junzhiit.nengji.cms.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.junzhiit.nengji.cms.service.HomeService;
import com.junzhiit.nengji.cms.service.TransactionService;
import com.junzhiit.nengji.cms.service.WechatFlowHistoryService;
import com.junzhiit.nengji.cms.web.vo.HomeTableVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/home")
public class HomeController extends BaseController{
	
	@Autowired
	private HomeService homeService;
	
	@Autowired
	private WechatFlowHistoryService wechatFlowHistoryService;
	
	@Autowired
	private TransactionService transactionService;
	
	@RequestMapping(value="/header",method=RequestMethod.GET)
	public ResultVO getheaderInfo(String sessionId){
		return homeService.getheaderInfo(sessionId);
	}
	
	@RequestMapping(value="/orders",method=RequestMethod.GET)
	public ResultVO queryOrdersInfo(String sessionId,Integer year,Integer month){
		return homeService.queryOrdersInfo(sessionId,year,month);
	}
	
	@RequestMapping(value="/goods",method=RequestMethod.GET)
	public ResultVO queryForGoods(String sessionId,int month){
		return homeService.queryForGoods(sessionId, month);
	}
	
	@RequestMapping(value="/notice",method=RequestMethod.GET)
	public ResultVO queryInternalNotice(){
		return homeService.queryInternalNotice();
	}
	
	@RequestMapping(value="/shop/notice",method=RequestMethod.GET)
	public ResultVO queryInternalShopNotice(){
		return homeService.queryInternalShopNotice();
	}
	
	@RequestMapping(value="/terrace/header",method=RequestMethod.GET)
	public ResultVO getHeaderStatistics(String sessionId){
		return homeService.getHeaderStatistics(sessionId);
	}
	
	@ApiOperation("查询总部首页订单数据")
	@RequestMapping(value="/all/orders",method=RequestMethod.GET)
	public ResultVO queryAllOrdersInfo(String sessionId,Integer year,Integer month){
		return homeService.queryAllOrdersInfo(sessionId,year, month);
	}
	
	@ApiOperation("查询总部首页流量数据")
	@RequestMapping(value="/flow",method=RequestMethod.GET)
	public ResultVO queryFlowInfo(Integer year,Integer month){
		return wechatFlowHistoryService.queryFlowInfo(year, month);
	}
	
	@ApiOperation("查询连锁品牌下的统计数据")
	@RequestMapping(value="/sso",method=RequestMethod.GET)
	public ResultVO queryTotal(String sessionId){
		return homeService.queryTotal(sessionId);
	}
	
	@ApiOperation("查询连锁品牌下的订单数据")
	@RequestMapping(value="/sso/orders",method=RequestMethod.GET)
	public ResultVO queryOrdersTotal(HomeTableVO homeTableVO){
		return transactionService.findChainTransaction(homeTableVO);
	}
	
	@ApiOperation("查询连锁品牌下的商品销售")
	@RequestMapping(value="/sso/goods",method=RequestMethod.GET)
	public ResultVO queryGoodsTotal(HomeTableVO homeTableVO){
		return homeService.querySsoGoods(homeTableVO);
	}
	
	@ApiOperation("查询连锁品牌下的店铺列表")
	@RequestMapping(value="/sso/shop",method=RequestMethod.GET)
	public ResultVO queryShopTotal(String sessionId){
		return homeService.queryAllShop(sessionId);
	}
	
	@ApiOperation("查询连锁品牌下的销售排行")
	@RequestMapping(value="/sso/income",method=RequestMethod.GET)
	public ResultVO queryShopIncome(HomeTableVO homeTableVO){
		return homeService.queryShopIncome(homeTableVO);
	}
}
